home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / dos / setfilesize.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-12  |  2.2 KB  |  94 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: setfilesize.c,v 1.1 1996/09/11 12:54:47 digulla Exp $
  4.     $Log: setfilesize.c,v $
  5.     Revision 1.1  1996/09/11 12:54:47  digulla
  6.     A couple of new DOS functions from M. Fleischer
  7.  
  8.     Desc:
  9.     Lang: english
  10. */
  11. #include <clib/exec_protos.h>
  12. #include <dos/dosextens.h>
  13. #include <dos/filesystem.h>
  14. #include "dos_intern.h"
  15.  
  16. /*****************************************************************************
  17.  
  18.     NAME */
  19.     #include <clib/dos_protos.h>
  20.  
  21.     __AROS_LH3(LONG, SetFileSize,
  22.  
  23. /*  SYNOPSIS */
  24.     __AROS_LHA(BPTR, file,   D1),
  25.     __AROS_LHA(LONG, offset, D2),
  26.     __AROS_LHA(LONG, mode,   D3),
  27.  
  28. /*  LOCATION */
  29.     struct DosLibrary *, DOSBase, 76, Dos)
  30.  
  31. /*  FUNCTION
  32.     Change the size of a file.
  33.  
  34.     INPUTS
  35.     file   - filehandle
  36.     offset - relative size
  37.     mode   - OFFSET_BEGINNING, OFFSET_CURRENT or OFFSET_END
  38.  
  39.     RESULT
  40.     New size of the file or -1 in case of an error.
  41.     IoErr() gives additional information in that case.
  42.  
  43.     NOTES
  44.  
  45.     EXAMPLE
  46.  
  47.     BUGS
  48.  
  49.     SEE ALSO
  50.  
  51.     INTERNALS
  52.  
  53.     HISTORY
  54.     29-10-95    digulla automatically created from
  55.                 dos_lib.fd and clib/dos_protos.h
  56.  
  57. *****************************************************************************/
  58. {
  59.     __AROS_FUNC_INIT
  60.     __AROS_BASE_EXT_DECL(struct DosLibrary *,DOSBase)
  61.  
  62.     /* Get pointer to filehandle */
  63.     struct FileHandle *fh=(struct FileHandle *)BADDR(file);
  64.  
  65.     /* Get pointer to process structure */
  66.     struct Process *me=(struct Process *)FindTask(NULL);
  67.  
  68.     /* Get pointer to I/O request. Use stackspace for now. */
  69.     struct IOFileSys io,*iofs=&io;
  70.  
  71.     /* Prepare I/O request. */
  72.     iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  73.     iofs->IOFS.io_Message.mn_ReplyPort   =&me->pr_MsgPort;
  74.     iofs->IOFS.io_Message.mn_Length      =sizeof(struct IOFileSys);
  75.     iofs->IOFS.io_Device =fh->fh_Device;
  76.     iofs->IOFS.io_Unit   =fh->fh_Unit;
  77.     iofs->IOFS.io_Command=FSA_READ;
  78.     iofs->IOFS.io_Flags  =0;
  79.     iofs->io_Args[0]=offset<0?-1:0;
  80.     iofs->io_Args[1]=offset;
  81.     iofs->io_Args[2]=mode;
  82.  
  83.     /* Send the request. */
  84.     DoIO(&iofs->IOFS);
  85.     
  86.     /* Set error code and return */
  87.     if((me->pr_Result2=iofs->io_DosError))
  88.         return -1;    
  89.     else
  90.         return iofs->io_Args[1];
  91.     
  92.     __AROS_FUNC_EXIT
  93. } /* SetFileSize */
  94.